package com.waigoulin.test.domain;

import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayApiException;
import com.waigoulin.domain.order.model.entity.PayOrderEntity;
import com.waigoulin.domain.order.model.entity.ShopCartEntity;
import com.waigoulin.domain.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * @FileName OrderServiceTest
 * @Description 订单服务领域层接口测试
 * @Author waigoulin
 * @date 2025-07-31
 **/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class OrderServiceTest {

    @Resource
    private IOrderService orderService;

    @Test
    public void testCreatePayOrder() throws AlipayApiException {
        ShopCartEntity shopCartEntity = ShopCartEntity.builder()
                .userId("waigoulin")
                .productId("10001")
                .build();
        log.info("请求参数:{}", JSON.toJSONString(shopCartEntity));
        PayOrderEntity payOrderEntity = orderService.createPayOrder(shopCartEntity);
        log.info("测试结果:{}", JSON.toJSONString(payOrderEntity));
    }
}


